#ifndef PORTSTATISTICS_H
#define PORTSTATISTICS_H

#include <QObject>

class PortStatistics : public QObject
{
    Q_OBJECT

    struct Info
    {
        long long m_receivedTotalBytes = 0;
        long long m_receivedCorrectBytes = 0;
        long long m_receivedErrorPackets = 0;
        long long m_receivedCorrectPackets = 0;

        long long m_sendTotalBytes = 0;
        long long m_sendPackets = 0;
    };

public:
    PortStatistics(QObject *parent = nullptr);
    virtual ~PortStatistics();

    void init();
    void print();

    void sendBytes(int bytes);
    void receiveBytes(int bytes);
    void receiveCorrectBytes(int bytes);


public slots:
    void on1sTimeout();

//private:
public:
    Info m_current;
    Info m_last;

    long long m_receivedBytesPerSecond = 0;
    long long m_receivedCorrectBytesPerSecond = 0;
    long long m_receivedErrorPacketsPerSecond = 0;
    long long m_receivedCorrectPacketsPerSecond = 0;

    long long m_sendBytesPerSecond = 0;
    long long m_sendPacketsPerSecond = 0;
};

#endif // PORTSTATISTICS_H
